import request from '@/utils/request'

/**
 * 入库分页查询
 * @param {*} data = {pageNo: 0, pageSize: 0, param: {likeName, storageType(服务入库), storeId}}
 */
export function pageList(form, pageSize, currentPage) {
  const data = {
    param: form,
    pageSize: pageSize,
    pageNo: currentPage
  }
  return request.post('/sq/brandInStorage/page', data)
}

/**
 * 精品分页查询
 * @param {*} data = {pageNo: 0, pageSize: 0, param: {inStorageId}}
 */
export function partsPage(form, pageSize, currentPage) {
  const data = {
    param: form,
    pageSize: pageSize,
    pageNo: currentPage
  }
  return request.post('/sq/brandInStorage/partsPage', data)
}

/**
 * 精品分页查询
 * @param {*} data = {pageNo: 0, pageSize: 0, param: {likeName, inStorageId, partsUnit(精品类别字典值),status}}
 */
export function partsDetailPage(form, pageSize, currentPage) {
  const data = {
    param: form,
    pageSize: pageSize,
    pageNo: currentPage
  }
  return request.post('/sq/brandInStorage/partsDetailPage', data)
}

/**
 * 新增入库
 * @param {*} data
 */
export function save(data) {
  return request.post('/sq/brandInStorage/save', data)
}

/**
 * 更新入库
 * @param {*} data
 */
export function update(data) {
  return request.put('/sq/brandInStorage/save', data)
}

/**
 * 删除入库
 * @param {*} id
 */
export function deleteById(id) {
  return request.delete(`/sq/brandInStorage/del/${id}`)
}

/**
 * 编辑入库详情
 * @param {*} id
 */
export function editDetailById(id) {
  return request.get(`/sq/brandInStorage/findById/${id}`)
}

/**
 * 入库详情
 * @param {*} id
 */
export function detailById(id) {
  return request.get(`/sq/brandInStorage/detail/${id}`)
}

/**
 * 获取入库编号
 */
export function getStorageCode() {
  return request.get(`/sq/brandInStorage/getStorageCode`)
}

/**
 * 查询来源单号
 */
export function findSourceCode(inStorageType, sourceCode) {
  return request.get(`/sq/brandInStorage/findSourceCode/${inStorageType}/${sourceCode}`)
}

